package com.plugins.usereflect;

import java.sql.SQLException;

import com.zxy.business.Ope_DB_Cent;
import com.zxy.common.Com_Fun;
import com.zxy.common.Db_Common_InterFace;
import com.zxy.common.PooledConnection_InterFace;
import com.zxy.model.T_PROC_NAME;

//清除冗余数据
public class T01_truncate_table_OUT implements com.zxy.common.ParamName_InterFace
{
	public StringBuilder	strResult		= new StringBuilder();
	public String			user_main_id			= null;
	public String			login_id			= null;
	public String			session_id		= null;
	public String			param_name		= null;
	public String			param_value1	= null;
	public String			param_value2	= null;
	public String			param_value3	= null;
	public String			param_value4	= null;
	public String			param_value5	= null;
	public String			param_value6	= null;
	public String			param_value7	= null;
	public String			param_value8	= null;
	public String			param_value9	= null;
	public String			param_value10	= null;
	
	public void init_start()
	{
		java.sql.ResultSet rs = null;
		//自动清除冗余数据
		StringBuilder sqlException = null;
		PooledConnection_InterFace pi = null;
		Db_Common_InterFace dbc = null;
		Ope_DB_Cent odc = new Ope_DB_Cent();
		try
		{
			Object dbcobject = odc.Get_Db_Common(1);
			dbc = (Db_Common_InterFace) (odc.Obj_To_Db_Common(dbcobject));
			pi = (PooledConnection_InterFace) dbc.getConn_a();
			T_PROC_NAME trn = new T_PROC_NAME();
			trn.INF_TYPE = "2";
			trn.INF_EN_SQL = "delete from t_btn_expand where TABLE_ID not in (select MAIN_ID from t_single_table);"
					+"delete from t_btn_role_link where ROLE_MAIN_ID not in (select MAIN_ID from t_role) or BTN_MAIN_ID not in (select MAIN_ID from t_button);"
					+"delete from t_btn_user_link where USER_MAIN_ID not in (select MAIN_ID from t_user_info) or BTN_MAIN_ID not in (select MAIN_ID from t_button);"
					+"delete from t_content_role_link where ROLE_MAIN_ID not in (select MAIN_ID from t_role) or MENU_MAIN_ID not in (select MAIN_ID from menu_info);"
					+"delete from t_content_user_link where USER_MAIN_ID not in (select MAIN_ID from t_user_info) or MENU_MAIN_ID not in (select MAIN_ID from menu_info);"
					+"delete from t_main_sub_link where MAIN_TB_NAME not in (select MAIN_ID from t_table_column) or SUB_TB_NAME not in (select MAIN_ID from t_table_column);";
			rs = dbc.Common_Sql_Proc("T01_truncate_table_OUT"
					,new String[0],new String[0],new String[0],new String[0],trn);
			sqlException = dbc.getSqlException();
			trn.INF_EN_SQL = "delete from t_menu_role_link where ROLE_MAIN_ID not in (select MAIN_ID from t_role) or MENU_MAIN_ID not in (select MAIN_ID from menu_info);"
					+"delete from t_menu_user_link where USER_MAIN_ID not in (select MAIN_ID from t_user_info) or MENU_MAIN_ID not in (select MAIN_ID from menu_info);"
					+"delete from t_proc_user_link where USER_MAIN_ID not in (select MAIN_ID from t_user_info) or PROC_ID not in (select MAIN_ID from t_proc_name);"
					+"delete from t_role_user_link where ROLE_MAIN_ID not in (select MAIN_ID from t_role) or USER_MAIN_ID not in (select MAIN_ID from t_user_info);"
					+"delete from t_single_expand where TABLE_ID not in (select MAIN_ID from t_single_table);";
			rs = dbc.Common_Sql_Proc("T01_truncate_table_OUT"
					,new String[0],new String[0],new String[0],new String[0],trn);
			sqlException = dbc.getSqlException();
			trn.INF_EN_SQL = "delete from t_table_column where TABLE_ID not in (select MAIN_ID from t_single_table);"
					+"delete from t_column_expand where COLUMN_ID not in (select MAIN_ID from t_table_column);"
					+"delete from menu_content where MENU_ID not in (select MAIN_ID from menu_info);"
					+"delete from menu_info where GROUP_ID not in (select MAIN_ID from menu_group);"
					+"";
			rs = dbc.Common_Sql_Proc("T01_truncate_table_OUT"
					,new String[0],new String[0],new String[0],new String[0],trn);
			sqlException = dbc.getSqlException();
		}
		catch(Exception e)
		{
			Com_Fun.debug_in(e,this.toString());
		}
		try
		{
			if(!java.util.Objects.equals(rs,null))
			{
				rs.getStatement().close();
				rs.close();
			}
			if(!java.util.Objects.equals(dbc,null) && !pi.isB_nocursor())
			{
				if(!java.util.Objects.equals(pi,null)
						&& !java.util.Objects.equals(pi.getCalls(),null))
					pi.getCalls().close();
			}else if(!java.util.Objects.equals(dbc,null))
			{
				pi.returnConnection();
			}
		}
		catch(SQLException e)
		{
		}
	}

	public StringBuilder getStrResult()
	{
		return strResult;
	}

	public void setStrResult(StringBuilder strResult)
	{
		this.strResult = strResult;
	}

	public String getUser_main_id()
	{
		return user_main_id;
	}

	public void setUser_main_id(String user_main_id)
	{
		this.user_main_id = user_main_id;
	}

	public String getSession_id()
	{
		return session_id;
	}

	public void setSession_id(String session_id)
	{
		this.session_id = session_id;
	}

	public String getParam_name()
	{
		return param_name;
	}

	public void setParam_name(String param_name)
	{
		this.param_name = param_name;
	}

	public String getParam_value1()
	{
		return param_value1;
	}

	public void setParam_value1(String param_value1)
	{
		this.param_value1 = param_value1;
	}

	public String getParam_value2()
	{
		return param_value2;
	}

	public void setParam_value2(String param_value2)
	{
		this.param_value2 = param_value2;
	}

	public String getParam_value3()
	{
		return param_value3;
	}

	public void setParam_value3(String param_value3)
	{
		this.param_value3 = param_value3;
	}

	public String getParam_value4()
	{
		return param_value4;
	}

	public void setParam_value4(String param_value4)
	{
		this.param_value4 = param_value4;
	}

	public String getParam_value5()
	{
		return param_value5;
	}

	public void setParam_value5(String param_value5)
	{
		this.param_value5 = param_value5;
	}

	public String getParam_value6()
	{
		return param_value6;
	}

	public void setParam_value6(String param_value6)
	{
		this.param_value6 = param_value6;
	}

	public String getParam_value7()
	{
		return param_value7;
	}

	public void setParam_value7(String param_value7)
	{
		this.param_value7 = param_value7;
	}

	public String getParam_value8()
	{
		return param_value8;
	}

	public void setParam_value8(String param_value8)
	{
		this.param_value8 = param_value8;
	}

	public String getParam_value9()
	{
		return param_value9;
	}

	public void setParam_value9(String param_value9)
	{
		this.param_value9 = param_value9;
	}

	public String getParam_value10()
	{
		return param_value10;
	}

	public void setParam_value10(String param_value10)
	{
		this.param_value10 = param_value10;
	}

	/**
	 * @return login_id
	 */
	public String getLogin_id()
	{
		return login_id;
	}

	/**
	 * @param login_id 要设置的 login_id
	 */
	public void setLogin_id(String login_id)
	{
		this.login_id = login_id;
	}
}
